home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / misc / gfront11.lha / GUIFront / Demos / Source / mystartup.c < prev    next >
C/C++ Source or Header  |  1994-06-14  |  762b  |  45 lines

  1.  
  2. /* Tinystartup.c - some very crude startup code for SAS/C */
  3.  
  4. #include <proto/exec.h>
  5. #include <proto/dos.h>
  6. #include <workbench/startup.h>
  7. #include <dos/dosextens.h>
  8.  
  9. struct ExecBase *SysBase;
  10. struct DosLibrary *DOSBase;
  11.  
  12. extern main(void);
  13.  
  14. __saveds startup(void)
  15. {
  16.     int rv = 0;
  17.  
  18.     SysBase = *((struct ExecBase **)4);
  19.  
  20.     if (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",36))
  21.     {
  22.         struct WBStartup *WBenchMsg;
  23.         struct Process *pr;
  24.  
  25.         pr = (struct Process *)FindTask(0);
  26.         if (!pr->pr_CLI)
  27.         {
  28.             WaitPort(&pr->pr_MsgPort);
  29.             WBenchMsg = (struct WBStartup *)GetMsg(&pr->pr_MsgPort);
  30.         }
  31.  
  32.         rv = main();
  33.  
  34.         CloseLibrary((struct Library *)DOSBase);
  35.  
  36.         if (!pr->pr_CLI)
  37.         {
  38.             Forbid();
  39.             ReplyMsg((struct Message *)WBenchMsg);
  40.         }
  41.     }
  42.  
  43.     return(rv);
  44. }
  45.